package com.qjc.demo.algorithm.对称数;

/**
 * @Description: 打印出 1-1000000 之间的所有对称数(例如 121、1331 等)
 * @Author: qjc
 * @Date: 2020/3/18
 */
public class SymmetryNumber {

    public static void main(String[] args) {
        for (int i = 1; i <= 1000000; i++) {
            if (isDuiChen(i)) {
                System.err.println(i);
            }
        }
    }

    private static boolean isDuiChen(int number) {
        String numString = String.valueOf(number);
        String reverseNumber = new StringBuffer(numString).reverse().toString();
        if (numString.equals(reverseNumber)) {
            return true;
        } else {
            return false;
        }
    }

}
